macromedia Your Account International Help
Products Support & Training DevNet Solutions Partners Downloads Store
Products Support & Training DevNet Solutions Partners Downloads Store
Home > Products > Director > Support > TechNote Index
Macromedia Director Support Center - TechNote

XML Xtra parser memory leak issue

Issue
Using the XML parser Xtra in Director (Windows: XMLParser.x32, Macintosh: XmlParser PPC Xtra) introduces a memory leak. The memory leak is initiated when commands such as parseURL or parseString are executed. For example:
gXMLObj.parseURL(the moviePath&"myXmlFile.xml").

The amount of memory leaked is dependent on the size of the XML file and the number of times the information is parsed.

Note: Depending on usage some users will never encounter a memory leak.

Workarounds
In Director MX the newObject from scripting was introduced, incorporating Flash objects inside Director MX. For more information on this method see Global Flash command for creating an ActionScript object (TechNote 16691) and the Director Designer & Developer Center. There is also information in the Director MX help. See Media > Using Flash and Other Interactive Media Types > Using Flash objects in Lingo. This new method uses Macromedia Flash and the FlashAsset Xtra to retrieve XML information. In this example Flash XML parsing capabilities are used. Below are two code examples.

1. Standard use of the XML Xtra in Director:
  The code example bellow represents a standard use of the XML Xtra and XML parsing. A memory leak might occur using this method.
 
----startMovie Script----
on startMovie
global pXMLObj  
  pXMLObj=new(xtra "XMLParser")
  pXMLObj.parseURL(the moviePath&"quiz.xml")
end startMovie
----startMovie Script----

----In a frame behavior----
global pXMLObj,gQuestionsList
on exitFrame me 
  if pXMLObj.doneParsing() then
    gQuestionsList=pXMLObj.makeList()
    --the handler below represents some property
-- list cleanup routine formatQuestionHandler() else
    go to the frame
  end if
end exitFrame
----In a frame behavior----
   
2. Code example for using the newObject method and XML parsing:
  This example makes use of the "newObject" method. Flash's XML parser accesses XML information. The code below can be used in a startMovie handler. See the downloadable sample file below. If no Flash sprites are used, the Flash Asset Xtra must be added to the Director MX movie.
  Note: This is just one of the many ways to create this functionality in Director.
 
----startMovie Script----
on startMovie
  XMLObj=newObject("XML")
  setCallback(XMLObj, "onLoad", #loadMyXML, 0)
  XMLObj.ignoreWhite=TRUE
  XMLObj.load("http://someURL")
end startMovie


on loadMyXML me, arg1, success
  if success = TRUE then
    --do something, like move to a new frame
    go to frame 3
    put "XML loaded="&success
  end if
end doXML
----startMovie Script----

Downloadable Director sample file. This download contains the following files:

> quiz.xml
> readMe_xml quiz.txt
> xml_quiz_newObj.dir

Download the zip file

Note: Please note that Macromedia does not provide technical support for sample files. For on-line information please see the Director Support Center. See the Director newsgroups and online forums for developer suggestions.

 



ID: 16805
Product: Director
Versions: MX
OS: All
Browser: All
Server: All
Database: All
Former ID: N/A
How useful was this document?
less more

1

2

3

4

5

How can the document be improved? (300 characters or less - you will not receive a reply.)

Last updated: February 25, 2003
Created: February 20, 2003